package com.ruoyi.web.zangchat.utils;

import com.ruoyi.web.zangchat.domain.mongoBean.MCommentBean;
import com.ruoyi.web.zangchat.domain.mongoBean.MTrendsBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
@Component
public class MongoDBUtil {
    @Autowired
    private MongoTemplate mongoTemplate;

    public void deleteById(String id){
        Query query=new Query(Criteria.where("id").is(id));
        mongoTemplate.remove(query, MTrendsBean.class);
    }

    public MTrendsBean findByTrendsId(Integer trendsId){
        Query  query=new Query(Criteria.where("trendsId").is(trendsId));
        MTrendsBean mTrendsBean = mongoTemplate.findOne(query, MTrendsBean.class);
        return mTrendsBean;
    }


}
